

(function (window) {
    var key = CryptoJS.enc.Utf8.parse("123456789ABCDEFG");
    var iv = CryptoJS.enc.Utf8.parse('123456789ABCDEFG');
    // 加密
    function Encrypt(word) {
        srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding:  CryptoJS.pad.ZeroPadding});
        return encrypted.ciphertext.toString().toUpperCase();
    }
    // 解密
    function Decrypt(word) {
        var encryptedHexStr = CryptoJS.enc.Hex.parse(word);
        var srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
        var decrypt = CryptoJS.AES.decrypt(srcs, key, {
            iv: iv, mode: CryptoJS.mode.CBC, padding:   CryptoJS.pad.ZeroPadding
        });
        var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
        return decryptedStr.toString();
    }

    window.Encrypt = Encrypt;
    window.Decrypt = Decrypt;
})(window)
